package com.jc.camerascan.widget;

import android.graphics.Rect;
import android.view.View;

import androidx.recyclerview.widget.RecyclerView;

/**
 * @ProjectName: PhotoRecognition
 * @Package: com.jc.camerascan.widget
 * @ClassName: SpaceItemDecoration
 * @Description: java类作用描述
 * @Author: XuChi
 * @CreateDate: 2020/7/14 16:35
 * @Version: 1.0
 */
public class SpaceItemDecoration  extends RecyclerView.ItemDecoration {

    private int space;
    private int left = 0;
    public SpaceItemDecoration(int space) {
        this.space = space;
    }
    public SpaceItemDecoration(int space, int left) {
        this.space = space;
        this.left = left;
    }
    @Override
    public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
        //不是第一个的格子都设一个左边和底部的间距
        outRect.left = left;
        outRect.bottom = space;
        //由于每行都只有3个，所以第一个都是3的倍数，把左边距设为0
//        if (parent.getChildLayoutPosition(view) %3==0) {
//            outRect.left = 0;
//        }
    }

}
